<template>
    <div style="padding: 20px;">
        <el-upload v-model:file-list="fileList" class="upload-demo" multiple :http-request="uploade">
            <el-button type="primary" v-auth="['upload']">上传附件</el-button>
        </el-upload>
        <el-button type="primary" size="default" @click="exportxlsx">导出</el-button>

        <el-table class="table" :data="tableData" border>
            <el-table-column prop="date" label="日期" width="180" />
            <el-table-column prop="name" label="姓名" width="180" />
            <el-table-column prop="address" label="地址" />
        </el-table>
        <el-button type="primary" size="default" @click="goChat">通信</el-button>
    </div>
</template>

<script setup>
import tool from '@/utils/tool.js'
import FileSaver from "file-saver";
import * as XLSX from 'xlsx'
import mock from 'mockjs'
const tableData = []

const fileList = ref([])
//上传文件之前的钩子
const uploade = (options) => {
    tool.oss.upload(options.file);
}
const exportxlsx = () => {
    let table = document.querySelector('.table')
    const xlparams = { raw: true }
    const wb = XLSX.utils.table_to_book(table, xlparams)
    const res = XLSX.write(wb, {
        type: 'array'
    })
    let bolb = new Blob([res])
    FileSaver.saveAs(bolb, '1.xlsx')
}
const goChat = () => {

}
</script>

<style lang="scss" scoped></style>